// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#[allow(unused_imports)]
use super::*;

#[doc(hidden)]
impl<'de> serde::de::Deserialize<'de> for super::CalendarAddOnManifest {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        #[allow(non_camel_case_types)]
        #[doc(hidden)]
        #[derive(PartialEq, Eq, Hash)]
        enum __FieldTag {
            __homepage_trigger,
            __conference_solution,
            __create_settings_url_function,
            __event_open_trigger,
            __event_update_trigger,
            __current_event_access,
            Unknown(std::string::String),
        }
        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
            where
                D: serde::Deserializer<'de>,
            {
                struct Visitor;
                impl<'de> serde::de::Visitor<'de> for Visitor {
                    type Value = __FieldTag;
                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
                        formatter.write_str("a field name for CalendarAddOnManifest")
                    }
                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
                    where
                        E: serde::de::Error,
                    {
                        use std::result::Result::Ok;
                        use std::string::ToString;
                        match value {
                            "homepageTrigger" => Ok(__FieldTag::__homepage_trigger),
                            "homepage_trigger" => Ok(__FieldTag::__homepage_trigger),
                            "conferenceSolution" => Ok(__FieldTag::__conference_solution),
                            "conference_solution" => Ok(__FieldTag::__conference_solution),
                            "createSettingsUrlFunction" => {
                                Ok(__FieldTag::__create_settings_url_function)
                            }
                            "create_settings_url_function" => {
                                Ok(__FieldTag::__create_settings_url_function)
                            }
                            "eventOpenTrigger" => Ok(__FieldTag::__event_open_trigger),
                            "event_open_trigger" => Ok(__FieldTag::__event_open_trigger),
                            "eventUpdateTrigger" => Ok(__FieldTag::__event_update_trigger),
                            "event_update_trigger" => Ok(__FieldTag::__event_update_trigger),
                            "currentEventAccess" => Ok(__FieldTag::__current_event_access),
                            "current_event_access" => Ok(__FieldTag::__current_event_access),
                            _ => Ok(__FieldTag::Unknown(value.to_string())),
                        }
                    }
                }
                deserializer.deserialize_identifier(Visitor)
            }
        }
        struct Visitor;
        impl<'de> serde::de::Visitor<'de> for Visitor {
            type Value = super::CalendarAddOnManifest;
            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
                formatter.write_str("struct CalendarAddOnManifest")
            }
            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
            where
                A: serde::de::MapAccess<'de>,
            {
                #[allow(unused_imports)]
                use serde::de::Error;
                use std::option::Option::Some;
                let mut fields = std::collections::HashSet::new();
                let mut result = Self::Value::new();
                while let Some(tag) = map.next_key::<__FieldTag>()? {
                    #[allow(clippy::match_single_binding)]
                    match tag {
                        __FieldTag::__homepage_trigger => {
                            if !fields.insert(__FieldTag::__homepage_trigger) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for homepage_trigger",
                                ));
                            }
                            result.homepage_trigger = map.next_value::<std::option::Option<
                                apps_script_type::model::HomepageExtensionPoint,
                            >>()?;
                        }
                        __FieldTag::__conference_solution => {
                            if !fields.insert(__FieldTag::__conference_solution) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for conference_solution",
                                ));
                            }
                            result.conference_solution = map
                                .next_value::<std::option::Option<
                                    std::vec::Vec<crate::model::ConferenceSolution>,
                                >>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::__create_settings_url_function => {
                            if !fields.insert(__FieldTag::__create_settings_url_function) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for create_settings_url_function",
                                ));
                            }
                            result.create_settings_url_function = map
                                .next_value::<std::option::Option<std::string::String>>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::__event_open_trigger => {
                            if !fields.insert(__FieldTag::__event_open_trigger) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for event_open_trigger",
                                ));
                            }
                            result.event_open_trigger = map.next_value::<std::option::Option<crate::model::CalendarExtensionPoint>>()?
                                ;
                        }
                        __FieldTag::__event_update_trigger => {
                            if !fields.insert(__FieldTag::__event_update_trigger) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for event_update_trigger",
                                ));
                            }
                            result.event_update_trigger = map.next_value::<std::option::Option<crate::model::CalendarExtensionPoint>>()?
                                ;
                        }
                        __FieldTag::__current_event_access => {
                            if !fields.insert(__FieldTag::__current_event_access) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for current_event_access",
                                ));
                            }
                            result.current_event_access = map
                                .next_value::<std::option::Option<
                                    crate::model::calendar_add_on_manifest::EventAccess,
                                >>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::Unknown(key) => {
                            let value = map.next_value::<serde_json::Value>()?;
                            result._unknown_fields.insert(key, value);
                        }
                    }
                }
                std::result::Result::Ok(result)
            }
        }
        deserializer.deserialize_any(Visitor)
    }
}

#[doc(hidden)]
impl<'de> serde::de::Deserialize<'de> for super::ConferenceSolution {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        #[allow(non_camel_case_types)]
        #[doc(hidden)]
        #[derive(PartialEq, Eq, Hash)]
        enum __FieldTag {
            __on_create_function,
            __id,
            __name,
            __logo_url,
            Unknown(std::string::String),
        }
        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
            where
                D: serde::Deserializer<'de>,
            {
                struct Visitor;
                impl<'de> serde::de::Visitor<'de> for Visitor {
                    type Value = __FieldTag;
                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
                        formatter.write_str("a field name for ConferenceSolution")
                    }
                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
                    where
                        E: serde::de::Error,
                    {
                        use std::result::Result::Ok;
                        use std::string::ToString;
                        match value {
                            "onCreateFunction" => Ok(__FieldTag::__on_create_function),
                            "on_create_function" => Ok(__FieldTag::__on_create_function),
                            "id" => Ok(__FieldTag::__id),
                            "name" => Ok(__FieldTag::__name),
                            "logoUrl" => Ok(__FieldTag::__logo_url),
                            "logo_url" => Ok(__FieldTag::__logo_url),
                            _ => Ok(__FieldTag::Unknown(value.to_string())),
                        }
                    }
                }
                deserializer.deserialize_identifier(Visitor)
            }
        }
        struct Visitor;
        impl<'de> serde::de::Visitor<'de> for Visitor {
            type Value = super::ConferenceSolution;
            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
                formatter.write_str("struct ConferenceSolution")
            }
            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
            where
                A: serde::de::MapAccess<'de>,
            {
                #[allow(unused_imports)]
                use serde::de::Error;
                use std::option::Option::Some;
                let mut fields = std::collections::HashSet::new();
                let mut result = Self::Value::new();
                while let Some(tag) = map.next_key::<__FieldTag>()? {
                    #[allow(clippy::match_single_binding)]
                    match tag {
                        __FieldTag::__on_create_function => {
                            if !fields.insert(__FieldTag::__on_create_function) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for on_create_function",
                                ));
                            }
                            result.on_create_function = map
                                .next_value::<std::option::Option<std::string::String>>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::__id => {
                            if !fields.insert(__FieldTag::__id) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for id",
                                ));
                            }
                            result.id = map
                                .next_value::<std::option::Option<std::string::String>>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::__name => {
                            if !fields.insert(__FieldTag::__name) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for name",
                                ));
                            }
                            result.name = map
                                .next_value::<std::option::Option<std::string::String>>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::__logo_url => {
                            if !fields.insert(__FieldTag::__logo_url) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for logo_url",
                                ));
                            }
                            result.logo_url = map
                                .next_value::<std::option::Option<std::string::String>>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::Unknown(key) => {
                            let value = map.next_value::<serde_json::Value>()?;
                            result._unknown_fields.insert(key, value);
                        }
                    }
                }
                std::result::Result::Ok(result)
            }
        }
        deserializer.deserialize_any(Visitor)
    }
}

#[doc(hidden)]
impl<'de> serde::de::Deserialize<'de> for super::CalendarExtensionPoint {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        #[allow(non_camel_case_types)]
        #[doc(hidden)]
        #[derive(PartialEq, Eq, Hash)]
        enum __FieldTag {
            __run_function,
            Unknown(std::string::String),
        }
        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
            where
                D: serde::Deserializer<'de>,
            {
                struct Visitor;
                impl<'de> serde::de::Visitor<'de> for Visitor {
                    type Value = __FieldTag;
                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
                        formatter.write_str("a field name for CalendarExtensionPoint")
                    }
                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
                    where
                        E: serde::de::Error,
                    {
                        use std::result::Result::Ok;
                        use std::string::ToString;
                        match value {
                            "runFunction" => Ok(__FieldTag::__run_function),
                            "run_function" => Ok(__FieldTag::__run_function),
                            _ => Ok(__FieldTag::Unknown(value.to_string())),
                        }
                    }
                }
                deserializer.deserialize_identifier(Visitor)
            }
        }
        struct Visitor;
        impl<'de> serde::de::Visitor<'de> for Visitor {
            type Value = super::CalendarExtensionPoint;
            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
                formatter.write_str("struct CalendarExtensionPoint")
            }
            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
            where
                A: serde::de::MapAccess<'de>,
            {
                #[allow(unused_imports)]
                use serde::de::Error;
                use std::option::Option::Some;
                let mut fields = std::collections::HashSet::new();
                let mut result = Self::Value::new();
                while let Some(tag) = map.next_key::<__FieldTag>()? {
                    #[allow(clippy::match_single_binding)]
                    match tag {
                        __FieldTag::__run_function => {
                            if !fields.insert(__FieldTag::__run_function) {
                                return std::result::Result::Err(A::Error::duplicate_field(
                                    "multiple values for run_function",
                                ));
                            }
                            result.run_function = map
                                .next_value::<std::option::Option<std::string::String>>()?
                                .unwrap_or_default();
                        }
                        __FieldTag::Unknown(key) => {
                            let value = map.next_value::<serde_json::Value>()?;
                            result._unknown_fields.insert(key, value);
                        }
                    }
                }
                std::result::Result::Ok(result)
            }
        }
        deserializer.deserialize_any(Visitor)
    }
}
